"""
@-*- coding: utf-8 -*-
@ python: 3.12.3
@ 创建者: JacksonCode
@ 创建时间: 2024/10/18
"""
import execjs

#  读取js文件
with open('test.js', 'r', encoding='utf-8') as f:
    js_code = f.read()

code = execjs.compile(js_code)
print(code)  # <execjs._exceptions.ProgramError: Cannot find module 'js2py'>  # 读取js文件
#  调用js函数
result = code.call('addFruit')

print(result)